<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
</html>

<script>
  // import HelloWorld from '@/components/HelloWorld.vue'
  const userMenuList = [
    {
      path: '/acl',
      name: '权限管理',
      component: 'Layout',
      children: [
        {
          path: 'user/list',
          name: '用户管理',
          component: '/acl/user/list'
        },
        {
          path: 'role/list',
          name: '角色管理',
          component: '/acl/role/list'
        },
        {
          path: 'menu/list',
          name: '菜单管理',
          component: '/acl/menu/list'
        }
      ]
    }
  ]

  const constantRoutes = [
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login'),
      hidden: true
    },
    {
      path: '/',
      name: '/',
      component: () => import('@/layout'),
      redirect: '/users',
      children: [
        {
          path: 'users',
          name: 'users',
          component: () => import('@/views/users/index.vue')
        },
        {
          path: 'categories',
          name: 'categories',
          component: () => import('@/views/categories/index.vue')
        },
        {
          path: 'goods',
          name: 'goods',
          component: () => import('@/views/goods/index.vue')
        },
        {
          path: 'orders',
          name: 'orders',
          component: () => import('@/views/orders/index.vue')
        },
        {
          path: 'params',
          name: 'params',
          component: () => import('@/views/params/index.vue')
        },
        {
          path: 'reports',
          name: 'reports',
          component: () => import('@/views/reports/index.vue')
        },
        {
          path: 'rights',
          name: 'rights',
          component: () => import('@/views/rights/index.vue')
        },
        {
          path: 'roles',
          name: 'roles',
          component: () => import('@/views/roles/index.vue')
        }
      ]
    }
  ]

  function getAllMenuList(userList, constantList) {
    const res = []
    constantList.forEach((item) => {
      if (item.children && item.children.length) {
        userList.forEach((child) => {
          item.children.push(child)
        })
      }
      res.push(item)
    })
    return res
  }

  const res = getAllMenuList(userMenuList, constantRoutes)
  console.log(res)
</script>
